package com.new2i.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.new2i.model.UserEntity;
import com.new2i.service.able.UserService;

/**
 * 用户视图控制器接口
 * @since 2015/08/26
 * @author 2i
 *
 */
@Controller
@RequestMapping("api/user")
public class UserApiAction extends BaseAction{

	@Autowired
	private UserService mUserService;
	
	@RequestMapping("/info/update")
	public void updateUserInfoByUserId(HttpServletRequest request,HttpServletResponse response,UserEntity user) { 
		Object oUserId = request.getSession().getAttribute("user_id");
		if(oUserId == null || oUserId.toString().length() <= 0){
			user.setUser_id(0);
		}else {
			int userId = Integer.parseInt(oUserId.toString());
			user.setUser_id(userId);
		}
		String value = mUserService.updateUserInfoByUserId(user);
		write2client(response, value);
	}
}
